import React, { Component } from 'react';
import { Modal, Form, Input,Radio,Select,DatePicker,Popconfirm ,Row,Col,Button,Icon,Upload, message,Table} from 'antd';
import styles from '../item.less';
import moment from 'moment';
import * as PurchaseModel from '../../model/purchase';
let role=JSON.parse(localStorage.user || "{}").role;
class _Main extends Component {

  constructor(props) {
    super(props);
    this.state = {orderBy:'createAt',filter:{},data:{list:[]},visible:false,visible1:false};
  }
  async cancel(id){
      console.log('正在取消中');
  }
  async setOut(item) { //status -> out
  console.log(zheng);
  }
  showModel=()=>{
    this.setState({
      visible: true,
    });
  }
   handleOk = (e) => {
    this.setState({
      visible: false,
    });
  }
  handleCancel = (e) => {
    this.setState({
      visible: false,
    });
  }
  showModelHandler =async (e) => {
    if (e) e.stopPropagation();
      this.setState({
        visible1: true,
      });
  }
  handleSubmit =async (e) => {
    if (e) e.stopPropagation();
      this.setState({
        visible1: false,
      });
  }
  hideModelHandler =async (e) => {
    if (e) e.stopPropagation();
      this.setState({
        visible1: false,
      });
  }
  render() {
    // let data=this.state.products;
    let data=this.props.list;
    const { children } = this.props;
    const id=this.state.id;
    // let num=Math.random()*99999;

    const columns = [
    {
      title: '编号',
      dataIndex: 'cnum',
      key: 'cnum',
      render: text => <span>{text}</span>
    },{
      title: '货运状态',
      dataIndex: 'status',
      key: 'status',
      render: text => <span>{text}</span>
    }, {
      title: '名字',
      dataIndex: 'name',
      key: 'name',
      render: text => <span>{text}</span>
    },{
      title: '集装箱号',
      dataIndex: 'box_order_num',
      key: 'box_order_num',
      render: text => <span>{text}</span>
    }, {
      title: '箱号',
      dataIndex: 'box_num',
      key: 'box_num',
      render: text => <span>{text}</span>
    }, {
      title: '箱数',
      dataIndex: 'box_quantity',
      key: 'box_quantity',
      render: text => <span>{text}</span>
    }];
    return (
      <span style={{fontSize:"14px",marginRight:15}}>
            <span onClick={this.showModelHandler}>
              { children }
            </span>
          <Modal
          title={this.props.record.cnum+'集装箱号的产品部件列表'}
          visible={this.state.visible1}
          onCancel={this.hideModelHandler}
          onOk={this.handleSubmit}
          width="90%"
        >
           <Table dataSource={this.props.record.components} columns={columns} pagination={false} rowKey="" />
         </Modal>
      </span>
    );
  }
}
export default _Main;
